<?
class wtforage extends module {

    // Author: Herman Tolentino MD
    // CHITS 2004

    function wtforage() {
    //
    // constructor
    // do not forget to update version
    //
        $this->author = 'Herman Tolentino MD';
        $this->version = "0.1-".date("Y-m-d");
        $this->module = "wtforage";
        $this->description = "CHITS Library - Weight for Age";
    }

    // --------------- STANDARD MODULE FUNCTIONS ------------------

    function init_deps() {
    //
    // insert dependencies in module_dependencies
    //
        module::set_dep($this->module, "module");

    }

    function init_lang() {
    //
    // insert necessary language directives
    // NOTES:
    //

    // not needed
    
    }

    function init_help() {
    }

    function init_menu() {
    //
    // menu entries
    // use multiple inserts (watch out for ;)
    //
        if (func_num_args()>0) {
            $arg_list = func_get_args();
        }

        // no menu
        // put in more details
        module::set_detail($this->description, $this->version, $this->author, $this->module);

    }

    function init_sql() {
    //
    // create module tables
    //
        if (func_num_args()>0) {
            $arg_list = func_get_args();
            $module_id = $arg_list[0];
        }

        module::execsql("CREATE TABLE `m_lib_wtforage` (".
            "`age` int(11) NOT NULL default '0',".
            "`weight` float NOT NULL default '0',".
            "`gender` char(1) NOT NULL default '',".
            "`class` varchar(10) NOT NULL default '',".
            "PRIMARY KEY  (`age`,`weight`,`gender`)".
            ") TYPE=MyISAM; ");

    }

    function drop_tables() {
    //
    // called from delete_module()
    //

        module::execsql("DROP TABLE `m_lib_wtforage`");
    }

    // --------------- CUSTOM MODULE FUNCTIONS ------------------

    function _wtforage() {
    //
    // main method for wtforage
    // caution -> use only for age 5 and below
    // call method:
    // $wt_class = wtforage ($age, $gender, $weight);
    // where $age = age of patient
    //              can be obtained from m_patient
    //       $gender = patient gender (M or F)
    //                 can be obtained from m_patient
    //       $weight = actual patient weight
    //                 can be obtained from m_consult_vitals
    // $wt_class: NORMAL, UNDERWEIGHT, OVERWEIGHT
    //
        // always check dependencies
        if ($exitinfo = $this->missing_dependencies('sms')) {
            return print($exitinfo);
        }
        if (func_num_args()>0) {
            $arg_list = func_get_args();
            $age_id = $arg_list[0];
            $gender = $arg_list[1];
            $actual_weight = $arg_list[2];
        }
        return $wt_class;
    }



}
?>
